import axios, { AxiosRequestConfig, AxiosResponse, AxiosError } from "axios";
import { ElMessage } from 'element-plus'

import { NprogressStart, Nprogressclose } from "@/utils/nprogress";

const service = axios.create({
  baseURL: "",
  timeout: 3000,
  headers: {},
});

service.interceptors.request.use((config: AxiosRequestConfig) => {
  NprogressStart();
  return config;
});

service.interceptors.response.use(
  (reponse: AxiosResponse) => {
    Nprogressclose()
    return reponse;
  },
  (error: AxiosError) => {
    console.log(error);
  }
);
